package com.xmb.wechat.view.alipay;

import android.app.Activity;
import android.content.Intent;
import android.text.TextUtils;
import android.widget.ImageView;
import android.widget.TextView;

import com.nil.sdk.utils.DateUtils;
import com.squareup.picasso.Picasso;
import com.xmb.wechat.R;
import com.xmb.wechat.R2;
import com.xmb.wechat.base.BaseActivity;
import com.xmb.wechat.entity.AliPayWithdrawEntity;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * @Author lijiangop
 * @CreateTime 2020/5/28 09:57
 */
public class AliPayWithdrawDetailActivity extends BaseActivity {

    @BindView(R2.id.iv_avatar)
    ImageView mIvAvatar;
    @BindView(R2.id.tv_avatar)
    TextView  mTvAvatar;
    @BindView(R2.id.tv_money)
    TextView  mTvMoney;
    @BindView(R2.id.tv_service_charge)
    TextView  mTvServiceCharge;
    @BindView(R2.id.tv_target_bank)
    TextView  mTvTargetBank;
    @BindView(R2.id.tv_start_time)
    TextView  mTvStartTime;
    @BindView(R2.id.tv_order_num)
    TextView  mTvOrderNum;
    @BindView(R2.id.tv_start_time1)
    TextView  mTvStartTime1;
    @BindView(R2.id.tv_start_time2)
    TextView  mTvStartTime2;
    @BindView(R2.id.tv_finish_time)
    TextView  mTvFinishTime;

    public AliPayWithdrawDetailActivity() {
        super(R.layout.activity_alipay_withdraw_detail);
    }

    public static void start(Activity activity, AliPayWithdrawEntity entity) {
        Intent intent = new Intent(activity, AliPayWithdrawDetailActivity.class);
        intent.putExtra("data", entity);
        activity.startActivity(intent);
    }

    @Override
    protected void initView() {
        AliPayWithdrawEntity entity = (AliPayWithdrawEntity) getIntent().getSerializableExtra("data");
        if (entity == null)
            return;
        Picasso.get().load(entity.getBankAvatar()).error(R.drawable.default_image).into(mIvAvatar);
        mTvAvatar.setText(TextUtils.isEmpty(entity.getBank()) ? "" : entity.getBank());
        mTvMoney.setText(TextUtils.isEmpty(entity.getMoney()) ? "" : entity.getMoney());
        mTvServiceCharge.setText(TextUtils.isEmpty(entity.getServiceCharge()) ? "" : entity.getServiceCharge());
        mTvTargetBank.setText(TextUtils.isEmpty(entity.getBankCard()) ? "" : entity.getBankCard() + " " + entity.getName());
        mTvStartTime.setText(TextUtils.isEmpty(entity.getStartTime()) ? "" : entity.getStartTime());
        mTvOrderNum.setText(TextUtils.isEmpty(entity.getOrderNum()) ? "" : entity.getOrderNum());

        mTvStartTime1.setText(getWithDrawTime(entity.getStartTime()));
        mTvStartTime2.setText(getWithDrawTime(entity.getStartTime()));
        mTvFinishTime.setText(getWithDrawTime(entity.getFinishTime()));
    }

    private String getWithDrawTime(String time) {
        if (TextUtils.isEmpty(time)) {
            return "";
        } else {
            return DateUtils.getStringByFormat(DateUtils.getDateByFormat(time, "yyyy-MM-dd HH:mm"), "MM-dd HH:mm");
        }
    }

    @OnClick(R2.id.iv_back)
    public void onViewClicked() {
        finish();
    }
}
